home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / crystal / porting < prev    next >
Encoding:
Text File  |  1988-01-12  |  2.3 KB  |  46 lines

  1. This version is "mostly" portable, except for
  2.     1) the usual index/strchr things
  3.     2) Some very funny (but easily eliminated) UNIX PC hacks.
  4.  
  5. The hacks are all designed to make it hard to read core files or the
  6. binary with strings(1).  After all, that would give away lots of the
  7. game.
  8.  
  9. For hackers wanting to change this, here's some basic information:
  10.  
  11. The stuff in the makefile relating to shlib.ifile does two things.  First,
  12. it makes the resulting binary use the UNIX PC shared library, which makes
  13. it smaller and faster than it would otherwise be.  Second, it supplies the
  14. addresses of the start and end of the initialized data region to the linker,
  15. and thus to cvinit.c.
  16.  
  17. Cvinit.c calls several routines to fix up a few problems with my C compiler
  18. (I don't think you have to pay any attention to this) and to encode the
  19. ASCII strings in the messages, objects and locations.  This encoding is done
  20. by encode() in cvspk.c.  Finally, the entire initialized data region is
  21. written to a file -- this depends on the memory treatment of the linker.
  22.  
  23. This encoded form is written back into the binary by the routine crycopy,
  24. since crystal is not allowed to write on itself.  Anyway, the result is that
  25. the binary contains the encoded forms of all these strings.
  26.  
  27. When strings are written out during play, this is done by putcode() in 
  28. cvspk.c, which reverses the encoding.  Thus, the sources have intelligible
  29. ASCII strings, but strings(1) cannot see them in the binaries or core files.
  30.  
  31. ------------------------------------
  32.  
  33. If all this gives you a headache, you can get rid of shlib.ifile (and also
  34. crt0s.o) and crycopy.  You will want to reorganize cvinit.c so that it is
  35. called regardless of the arguments to crystal, because of the other fixup work
  36. that it does.  The result will be that the strings are encoded at the start of
  37. each run, so that core files are still unreadable, but the binary can be
  38. browsed.  You will want to remove the invocation of crystal in the makefile.
  39.  
  40. I'm sure there are better ways to do this encoding stuff, my only excuse is that
  41. this is my very first C program, and I never even knew there was BSD at the
  42. time, and had not a hint about the ways in which UNIX implementations differ.
  43. This was written for the AT&T 7300, with no help from (or access to) UNIX or
  44. C expertise other than the manuals I got with my machine.  What the hey, it
  45. works fine on MY machine.
  46.